]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageList: Give focus to next message on delete
authorDylan McCall <dylan@dylanmccall.ca>
Mon, 29 Nov 2021 00:19:35 +0000 (16:19 -0800)
committerMarge Bot <marge-bot@gnome.org>
Wed, 1 Dec 2021 10:19:54 +0000 (10:19 +0000)
When the user deletes a message using the keyboard, set the keyboard
focus to the next message, or to the list container itself, so it
remains possible to navigate using the keyboard.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/502
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2053>

js/ui/messageList.js

index 8ffdaebc133c76efaacc7bcd86e0c249f41f32e2..77672a59287dd074a2b224e19c682dedefb2c8ed 100644 (file)
@@ -663,12 +663,24 @@ var MessageListSection = GObject.registerClass({
     }
 
     removeMessage(message, animate) {
-        if (!this._messages.includes(message))
+        const messages = this._messages;
+
+        if (!messages.includes(message))
             throw new Error(`Impossible to remove untracked message`);
 
         let listItem = message.get_parent();
         listItem._connectionsIds.forEach(id => message.disconnect(id));
 
+        let nextMessage = null;
+
+        if (message.has_key_focus()) {
+            const index = messages.indexOf(message);
+            nextMessage =
+                messages[index + 1] ||
+                messages[index - 1] ||
+                this._list;
+        }
+
         if (animate) {
             listItem.ease({
                 scale_x: 0,
@@ -677,10 +689,12 @@ var MessageListSection = GObject.registerClass({
                 mode: Clutter.AnimationMode.EASE_OUT_QUAD,
                 onComplete: () => {
                     listItem.destroy();
+                    nextMessage?.grab_key_focus();
                 },
             });
         } else {
             listItem.destroy();
+            nextMessage?.grab_key_focus();
         }
     }